
package com.hc.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.hc.dao.IRoleDao;
import com.hc.dao.IUserAndRoleDao;
import com.hc.domain.Role;
import com.hc.service.IRoleService;
@Service("roleService")
public class RoleServiceImpl implements IRoleService {
	@Resource
	private IRoleDao roleDao;
	@Resource
	private IUserAndRoleDao userAndRoleDao;

	@Override
	public List<Role> findAll() {
		return roleDao.findAll();
		
	}

	@Override
	public Role getRoleByRoleName(String roleName) {
		return roleDao.getRoleByRoleName(roleName);
		
	}

	@Override
	public void updateOrSave(Role role) {
		roleDao.updateOrSave(role);
	}

	@Override
	public Role getRoleById(int id) {
		return roleDao.getRoleById(id);
		
	}

	@Override
	public void deleteRole(Role role) {
		roleDao.deleteRole(role);
	}

	@Override
	public void deleteRoleAndAuth(Role role) throws Exception {
		deleteRole(role);
		userAndRoleDao.deleteUserAuthByRole(role);
	}

	@Override
	public List<Role> getRoleByEmployeeId(int id) {
		return roleDao.getRoleByEmployeeId(id);
		
	}

}

